import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'normalize.css'
import './assets/css.less'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import '../src/utils/request';  //引入axios配置
import axios from 'axios';

Vue.use(ElementUI);
Vue.config.productionTip = false

Vue.prototype.axios = axios;

import VueCoreVideoPlayer from 'vue-core-video-player'
// Vue.use(VueCoreVideoPlayer)
//或者
Vue.use(VueCoreVideoPlayer, {
    lang: 'zh-CN'
})

router.beforeEach((to, from, next) => {
    if (to.path === '/') {
        sessionStorage.clear()
        next();
    } else {
        let Authorization = sessionStorage.getItem('tokenValue');
        if (!Authorization) {
            sessionStorage.clear()
            next({path: '/'});
        } else {
            next();
        }
    }
    // if (!Authorization){
    //   sessionStorage.clear();
    //   next({path: '/'});
    // }
    // if (to.path === '/logout') {
    //   //清空
    //   sessionStorage.clear();
    //   //跳转到登录页面
    //   next({path: '/login'});
    // } else if (to.path === '/home') {
    //   //判断是否为空
    //   if (Authorization != null) {
    //     next({path: '/main'})
    //   }
    // } else if (Authorization == null) {
    //   next({path: '/login'})
    // }
    // next();
});

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
